/**
 * 
 */
package common.liusany.admin.dao.account;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.liusany.modules.orm.hibernate.HibernateDao;
import common.liusany.admin.entity.account.Email;

/**
 * @author Administrator
 *
 */
@Component

public class EmailDao extends HibernateDao<Email, Long> {
	private static Logger logger = LoggerFactory.getLogger(EmailDao.class);
	
	public void deleteAll(){
		String sql = "truncate TABLE acct_email";
		int count = getSession().createSQLQuery(sql).executeUpdate();
		logger.info("删除数据" + count + "条");
	}
	
	
	@SuppressWarnings("unchecked")
	public List<Email> getList(int start,int end){
	 return  (List<Email>)getSession().createQuery("from Email where sendStatus = 'unsend'")
	 .setFirstResult(start).setMaxResults(end).list();
	}
	
	/**
	 * 查询未发送的邮箱
	 * @author:liufei
	 * @param maxResult 每次查询条数
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Email> getList(int maxResult){
	 return  (List<Email>)getSession().createQuery("from Email where sendStatus = 'unsend'")
	 .setMaxResults(maxResult).list();
	}
	
}
